package com.future.direction.ui.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.future.direction.R;
import com.future.direction.common.util.UIUtil;
import com.future.direction.data.bean.StudyRecordsBean;
import com.future.direction.data.bean.StudyRecordsItemBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhp on 2019-11-20
 */
public class StudyRecordsAdapter extends BaseQuickAdapter<StudyRecordsBean, BaseViewHolder> {
    public StudyRecordsAdapter(int layoutResId, @Nullable List<StudyRecordsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, StudyRecordsBean item) {

        List<StudyRecordsItemBean> studyRecordsItemBeans = new ArrayList<>();
        for (int i = 0; i < helper.getAdapterPosition() + 1; i++) {
            studyRecordsItemBeans.add(new StudyRecordsItemBean());
        }
        if (helper.getAdapterPosition() == 0) {
            helper.setBackgroundRes(R.id.iv_study_color, R.drawable.yuan_dot_accent);
        } else {
            helper.setBackgroundRes(R.id.iv_study_color, R.drawable.yuan_dot_gray);
        }

        RecyclerView recycleItemStudyRecords = helper.getView(R.id.recycle_item_study_records);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(UIUtil.getContext(), LinearLayoutManager.VERTICAL, false);
        recycleItemStudyRecords.setLayoutManager(linearLayoutManager);
        StudyRecordsItemAdapter studyRecordsItemAdapter = new StudyRecordsItemAdapter(R.layout.item_study_records_item, studyRecordsItemBeans);
        recycleItemStudyRecords.setAdapter(studyRecordsItemAdapter);
    }

}
